import 'package:flutter/material.dart';
import 'package:module_discover/pages/model/filter_model.dart';

/// checkBox类型
class ChildBxoWidget extends StatefulWidget {
  BaseFilterItem? option;
  bool? isCheck;
  final ValueChanged<bool?>? onChanged;

  ChildBxoWidget(
      {super.key, this.option, this.isCheck = false, this.onChanged});

  @override
  State<ChildBxoWidget> createState() => _ChildBxoWidgetState();
}

class _ChildBxoWidgetState extends State<ChildBxoWidget> {
  @override
  Widget build(BuildContext context) {
    return Container(
      height: 32,
      padding: const EdgeInsets.symmetric(horizontal: 8),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
          SizedBox(
            width: 20,
            height: 20,
            child: Checkbox(
              value: widget.isCheck,
              onChanged: (bool? value) {
                setState(() {
                  widget.isCheck = !(widget.isCheck ?? false);
                  if (widget.onChanged != null) {
                    widget.onChanged!(value);
                  }
                });
              },
              activeColor: Colors.red,
              checkColor: Colors.white,
              shape: const CircleBorder(),
              side: BorderSide(
                color: Colors.grey[400]!,
                width: 1.5,
              ),
              materialTapTargetSize: MaterialTapTargetSize.padded,
            ),
          ),
          const SizedBox(width: 10),
          // 描述文本
          Text(
            '${widget.option?.title}',
            style: TextStyle(
                fontSize: 10, color: Colors.black, letterSpacing: 0.5),
          ),
        ],
      ),
    );
  }
}
